{extend name="index/base" /}
{block name="content"}
<blockquote class="layui-elem-quote fhui-admin-main_hd">
    <h2>拦截DLL配置列表（先配置dll，再配置process)</h2>
</blockquote>

<div class="y-role">
    <!--工具栏-->
    <div id="floatHead" class="toolbar-wrap">
        <div class="toolbar">
            <div class="box-wrap">
                <a class="menu-btn"></a>
                <div class="l-list">
                    <a class="layui-btn" href="javascript:;" id="addBtn"><i class="fa fa-plus"></i> 添加</a>
                    <a class="layui-btn do-action" onclick="window.location.reload()"><i class="fa fa-refresh fa-spin"></i> 刷新</a>
                </div>
            </div>
        </div>
    </div>
    <!--/工具栏-->
    <!--文字列表-->
    <div class="fhui-admin-table-container">
        <table id="table1" lay-filter="table1"></table>
    </div>
</div>

<script type="text/html" id="barDemo">
    <a class="layui-btn layui-btn-xs" lay-event="edit">设置DLL</a>
    <a class="layui-btn layui-btn-xs" lay-event="editprocess">设置process</a>
    <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>
</script>
<script type="text/html" id="status">
    {{# if(d.status == 1) { }}
    <a style="color: green;">启用</a>
    {{# } else if(d.status==0) { }}
    <a style="color: red;">禁用</a>
    {{# } }}
</script>

{/block}
{block name="js"}
<script type="text/javascript">
    layui.use(['table','jquery','form','upload'], function(){
        var table = layui.table;var form = layui.form;var upload = layui.upload;
        var $ = layui.$;
        var inittable = table.render({
            elem: '#table1'
            ,height: '700'
            ,url: '{:url("tackledllsList")}'
            ,page: true //开启分页
            ,limit: 20
            ,cols: [[ //表头
                {field: 'id', title: 'ID', width:70, fixed: 'left'}
                ,{field: 'dll', title: 'dll'}
                ,{field: 'process', title: 'process'}
                ,{field: 'status', title: '状态', templet:'#status'}
                ,{fixed: 'right','title':'操作', align:'center', templet: '#barDemo'}
            ]]
        });

        // 编辑的弹窗和删除
        table.on('tool(table1)', function(obj){
            var data = obj.data; //获得当前行数据
            if (obj.event === 'del'){
                layer.confirm('您确定要删除吗？', function(index){
                    var loading = layer.load(1, {shade: [0.1, '#fff']});
                    $.post("{:url('deltackledlls')}",{id:data.id},function(res){
                        layer.close(loading);
                        if(res.code===0){
                            layer.msg(res.msg,{time:500,icon:1});
                            obj.del();
                        }else{
                            layer.msg('操作失败！',{time:1000,icon:2});
                        }
                    });
                    layer.close(index);
                });
            } else if(obj.event === 'edit') {
                layer.open({
                    type:2,
                    title:'编辑DLL信息',
                    area: ['600px', '700px'],
                    scrollbar: false,
                    shadeClose: true,
                    content:"{:url('edittackledlls')}?id="+data.id,
                    end: function(layero, index) {
                        inittable.reload();
                    }
                })
            } else if(obj.event === 'editprocess') {
                layer.open({
                    type:2,
                    title:'编辑process',
                    area: ['600px', '700px'],
                    scrollbar: false,
                    shadeClose: true,
                    content:"{:url('editTackledllsProcess')}?id="+data.id,
                    end: function(layero, index) {
                        inittable.reload();
                    }
                })
            }
        });

        //刷新
        $('#reload_btn').click(function(){
            var keywords = $('#keywords').val();
            inittable.reload({
                where:{
                    keywords:keywords
                },
                page:{
                    curr:1
                }
            })
        });

        $('#addBtn').click(function(){
            layer.open({
                type:2,
                title:'添加浏览器父进程',
                area: ['600px', '700px'],
                scrollbar: false,
                shadeClose: true,
                content:"{:url('addtackledlls')}",
                end: function(layero, index) {
                    inittable.reload();
                }
            })
        })
    });
</script>
{/block}